#include <iostream>

using namespace std;


enum {__ALIGN=8};
enum {__MAX_BYTES=128};
enum {__NFREELISTS = __MAX_BYTES/__ALIGN};

class __default_alloc_template
{
private:
    static size_t ROUND_UP(size_t bytes)
    {
        return (((bytes) + __ALIGN - 1) & ~(__ALIGN - 1));
    }

private:
    union obj
    {
        union obj *free_list_link;
        char client_data[1];
    };

private:
    static obj * free_list[__NFREELISTS];
    static size_t FREELIST_INDEX(size_t bytes)
    {
        return (((bytes) + __ALIGN - 1)/__ALIGN - 1);
    }

    static void *refill(size_t n);

    static char *chunk_alloc(size_t size, int &nobjs);

public:
    static char *start_free;
    static char *end_free;
    static size_t heap_size;

public:
    static void *allocate(size_t n);
    static void deallocate(void *p, size_t n);
    static void *reallocate(void *p, size_t old_sz, size_t new_sz);
};
